﻿namespace Arcthitectrue.Common
{
    /// <summary>
    /// 扩展类
    /// 里面定义的是扩展方法
    /// 用this作为类型扩展的关键字
    /// 类和方法必须是静态的
    /// </summary>
    public static class Extensions
    {
        /// <summary>
        /// 扩展字符串转数字
        /// </summary>
        /// <returns></returns>
        public static int ToInt32(this string? value)
        {

            if (value == null)
            {

                return 0;
            }
            else
            {

                return Convert.ToInt32(value);
            }
                
        }

        /// <summary>
        /// 根据身份证计算年月日
        /// </summary>
        /// <param name="carId"></param>
        /// <returns></returns>
        public static string GetBitthByCarId(this string carId)
        {
            
           

            string reuslt = carId.Substring(6, 8);
            return reuslt;


        }

        /// <summary>
        /// 日期转 yyyy年MM月dd日
        /// </summary>
        /// <param name="date"></param>
        /// <returns></returns>
        public static string GetStringTime(this DateTime date)
        {
            string time = date.ToString("yyyy年MM月dd日");
            return  time;
        
        }


    }
}
